class Solution {
public:
    double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) {
        vector<int> ne;
        int m = nums1.size();int n = nums2.size();
        int i = 0;int j = 0;
        while(i != m || j != n)
        {
            if(i != m && j != n)
            {
                if(nums1[i] >=nums2[j]){
                    ne.push_back(nums2[j]);
                    j++;
                }else{
                    ne.push_back(nums1[i]);
                    i++;
                }
            }
            if(i == m)
            {
                while(j != n)
                {
                    ne.push_back(nums2[j]);
                    j++;
                }
            }
            if(j == n)
            {
                while(i != m)
                {
                    ne.push_back(nums1[i]);
                    i++;
                }
            }
        }
        if(ne.size() % 2 == 0)
        {
            return (ne[ne.size()/2 - 1] + ne[ne.size()/2]) / 2.0;
        }else{
            return (double)ne[ne.size() / 2];
        }
    }
};
